
// worker.js
const { isMainThread, parentPort } = require('worker_threads');
const downCter = require("../controller/down.cter.js");
if (isMainThread) {
    throw new Error('Its not a worker');
}
// 子线程执行
const taskFun = (data) => {
    return new Promise(async (resolve, reject) => {
        console.log("子线程得到", data.user.mobile);
        let orderInfo = await downCter.downloadImg({ ...data, downType: 1 });
        resolve(orderInfo);
    })
};
//2.子线程接收传过来的数据，并进行cpu耗时操作
parentPort.on('message', async (data) => {
    const result = await taskFun(data);
    parentPort.postMessage(result);
});